package com.example.service;

import com.example.entity.SysOrganization;
import com.example.mapper.SysOrganizationMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysOrganizationService {

    @Resource
    private SysOrganizationMapper sysOrganizationMapper;

    public List<SysOrganization> selectAll(SysOrganization sysOrganization) {
        return sysOrganizationMapper.selectAll(sysOrganization);
    }

    //分页查询
    public PageInfo<SysOrganization> selectPage(SysOrganization sysOrganization, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<SysOrganization> list = sysOrganizationMapper.selectAll(sysOrganization);
        return PageInfo.of(list);
    }

    public void add(SysOrganization sysOrganization) {
        sysOrganizationMapper.insert(sysOrganization);
    }

    public void update(SysOrganization sysOrganization) {
        sysOrganizationMapper.update(sysOrganization);
    }

    public void delete(Integer id) {
        sysOrganizationMapper.delete(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            sysOrganizationMapper.delete(id);
        }
    }

}
